<?php
include("student_lock.php");
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<title>Student Add Class</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script src="jquery.js" type="text/javascript"></script> 
<script TYPE="TEXT/JAVASCRIPT">
<?php
	echo "var login = '$login';";
?>

function subjectSelectorHandler(input)
{
//	location.href="student.php?sem="+a[0]+"&yr="+a[1];
	$.ajax({url: 'ajax_student_course.php?department='+input, success: function(data){document.getElementById('courseNumber').innerHTML=data;}});
}

function courseSelectorHandler(input)
{
	$.ajax({url: 'ajax_student_section.php?id='+input, success: function(data){document.getElementById('sectionNumber').innerHTML=data;}});
	$.ajax({url: 'ajax_student_description.php?id='+input, success: function(data){document.getElementById('description').innerHTML=data;}});
}

function sectionSelectorHandler(input)
{
		//alert(input);
		a = input.split('_');
		alert(a[0]+"-"+a[1]);
		$.ajax({url: 'ajax_student_section_description.php?id='+a[0]+'&sec_id='+a[1], success: function(data){document.getElementById('description').innerHTML=data;}});
}
</script>

</head>

<body>
<table align="center">
<tr>
<td width="200">
<?php
//****get student's name********
	$login = $_SESSION["login_user"];
	$result=mysql_query("select first from student where id='$login'");
	$row=mysql_fetch_array($result);
	$name = $row['first'];
//******************************
echo "Welcome: ".$name; 
?></td>
<td width="400" align="center"><h1>Student: Add Class</h1></td>
<td width="200" align="right"><a href="logout.php">Logout</a></td>
</tr>
</table>

<table width=800" align="center">
	<tr>
	<td colspan="3" align="right"> 
	</td>
	</tr>
<tr>
<td width="250" align="center"><B>Subject</B> </td>
<td width="250" align="center" style="margin-left:100 "><b>Course Number</b></td>
<td width="250" align="center" style="margin-left:100 "><b>Section Number</b></td>
</tr>
<tr>
<td align="center">
<div id="subjectList">
<?php
	
	$result=mysql_query("SELECT * FROM department ORDER BY name");
	$row=mysql_fetch_array($result);
	
	echo "<form action='' name='subjectForm'>";
	echo "<SELECT NAME='subject' SIZE='10' onchange=\"subjectSelectorHandler(document.subjectForm.subject.value);\" MULTIPLE>";
	echo "<OPTION SELECTED value='".$row['short_name']."'>".$row['name'];
	
	while ($row=mysql_fetch_array($result))
	{
		echo "<OPTION value='".$row['short_name']."'>".$row['name'];
	}
	
	echo "</SELECT>";
	echo "</form>";
?>
</div>
</td>
<td align="center">
<div id="courseNumber">
<!-- coourse stuff goes here-->  



</div>
</td>
<td align="center">
<div id="sectionNumber">
<!-- section stuff goes here-->  
  
  
  
  
</div>
</td>
</tr>
<tr><td><br></td></tr>
<tr>
<td colspan="2" align="center">
<b>Course Description</b>
</td>
<td align="center">
<b>Currently Selected</b>
</td>
</tr>

<tr>
<td colspan="2">
<div id="courseDescription">
<form name=courseDescriptn>
<textarea id="description" name=mytextarea cols=80 rows=10 readonly>
<!--Description goes here-->




</textarea> 
</form>
</div>
</td>

<td align="center">
<div id="sectionNumber">
  <select name="select" size="10" multiple >
    <option selected> 0
    <option> 1
    <option> 2
    <option> 3
    <option> 4
    <option> 5
    <option> 6
    <option> 7
    <option> 8
  </select>
</div>
</td>
</tr>

<tr>
<td colspan="2"></td>
<td width="200" align="center"><input type="Submit" value="Add Selected Courses"></td>
</tr>
</table>
<br><br><br>


</body>
</html>
